/**
 * 图表
 */

import * as Echarts from 'echarts';

export default (info = {}, dom) => {
  const { list = [] } = info || {};
  const data = [];
  const xAxisData = [];
  list &&
    list.reverse().forEach((item, index) => {
      xAxisData.push(item.time);
      data.push(item.count);
    });
  const isShow = list && list.length;
  const echart = Echarts.init(dom);
  const option = {
    title: {
      top: 10,
      text: '流量',
      textStyle: {
        color: '#fff',
        fontFamily: 'webfont',
        fontSize: 15,
        fontWight: 'lighter',
      },
    },
    tooltip: {
      trigger: 'axis',
    },
    grid: {
      top: '12%',
      left: '2%',
      right: '2%',
      bottom: '6%',
      containLabel: true,
    },
    xAxis: {
      data: xAxisData,
      axisLabel: {
        color: '#cccccc',
      },
    },
    yAxis: {
      type: 'value',
      splitLine: {
        show: false,
      },
      axisLabel: {
        color: '#cccccc',
      },
    },

    series: {
      type: 'line',
      data,
      areaStyle: {},
      smooth: true,
      symbol: 'none', // 不显示点
      itemStyle: {
        color: '#008B8B',
      },
      lineStyle: {
        width: 1,
      },
    },
  };

  echart.setOption(option);
  return echart;
};
